package com.erps.dao;

import com.erps.CommonUtils.ActiveField;
import com.erps.CommonUtils.DateUtils;
import com.erps.CommonUtils.JActiveField;
import com.erps.CommonUtils.JActiveTable;
import com.erps.CommonUtils.Sequence;
import com.erps.db.DBManager;
import com.hmkj.entity.ErspResStand;

public class ErspResStandDao extends JActiveTable {
	public ErspResStandDao() {
		setDBTableName("ersp_res_stand");
		AddField(new JActiveField("id", "id", ActiveField.ftString, 36));
		setDefaultFieldValue("id", Sequence.getGuid());

		AddField(new JActiveField("res_id", "res_id", ActiveField.ftString, 36));
		AddField(new JActiveField("res_intro", "res_intro", ActiveField.ftString, 36));
		AddField(new JActiveField("res_equipment", "res_equipment", ActiveField.ftString, 200));
		AddField(new JActiveField("res_areasize", "res_areasize", ActiveField.ftString, 100));

		AddField(new JActiveField("res_popsize", "res_popsize", ActiveField.ftString, 50));
		AddField(new JActiveField("res_addr", "res_addr", ActiveField.ftString, 200));

		AddField(new JActiveField("res_instrument", "res_instrument", ActiveField.ftString, 200));
		AddField(new JActiveField("res_singleusetime", "res_singleusetime", ActiveField.ftString, 50));
		AddField(new JActiveField("res_recommandgroup", "res_recommandgroup", ActiveField.ftString, 200));
		AddField(new JActiveField("res_recommandflag", "res_recommandflag", ActiveField.ftString, 1));

		AddField(new JActiveField("res_opentime", "res_opentime", ActiveField.ftString, 200));
		AddField(new JActiveField("res_first_typeid", "res_first_typeid", ActiveField.ftInteger,6));
		AddField(new JActiveField("res_second_typeid", "res_second_typeid", ActiveField.ftInteger,6));

		AddField(new JActiveField("res_posx", "res_posx", ActiveField.ftDouble,0));
		AddField(new JActiveField("res_posy", "res_posy", ActiveField.ftDouble,0));

		AddField(new JActiveField("last_update_time", "last_update_time", ActiveField.ftLong));
		setDefaultFieldValue("last_update_time", String.valueOf(DateUtils.getDayTimeNum()));

		setDbKeyFields("id");

	}

	public int add(ErspResStand vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("res_intro", vo.getRes_intro());
		setFieldValue("res_equipment", vo.getRes_equipment());
		setFieldValue("res_areasize", vo.getRes_addr());
		setFieldValue("res_addr", vo.getRes_addr());
		setFieldValue("res_instrument", vo.getRes_instrument());
		setFieldValue("res_singleusetime", vo.getRes_singleusetime());
		setFieldValue("res_recommandgroup", vo.getRes_recommandgroup());
		setFieldValue("res_recommandflag", vo.getRes_recommandflag());
		setFieldValue("res_opentime", vo.getRes_opentime());
		setFieldValue("res_first_typeid", vo.getRes_first_typeid());
		setFieldValue("res_second_typeid", vo.getRes_second_typeid());
		setFieldValue("res_posx", vo.getRes_posx());
		setFieldValue("res_posy", vo.getRes_posy());

		return DBManager.ExecSQL(this.getSQL());
	}
	public String getSQL(ErspResStand vo) {
		setFieldValue("id", vo.getId());
		setFieldValue("res_intro", vo.getRes_intro());
		setFieldValue("res_equipment", vo.getRes_equipment());
		setFieldValue("res_areasize", vo.getRes_addr());
		setFieldValue("res_addr", vo.getRes_addr());
		setFieldValue("res_instrument", vo.getRes_instrument());
		setFieldValue("res_singleusetime", vo.getRes_singleusetime());
		setFieldValue("res_recommandgroup", vo.getRes_recommandgroup());
		setFieldValue("res_recommandflag", vo.getRes_recommandflag());
		setFieldValue("res_opentime", vo.getRes_opentime());
		setFieldValue("res_first_typeid", vo.getRes_first_typeid());
		setFieldValue("res_second_typeid", vo.getRes_second_typeid());
		setFieldValue("res_posx", vo.getRes_posx());
		setFieldValue("res_posy", vo.getRes_posy());
		return this.getSQL();
	}
}
